1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect.testing;
18
19 import com.google.common.annotations.GwtCompatible;
20
21 import java.util.Collection;
22
23
24
25
26
27
28
29
30 @GwtCompatible
31 public abstract class AbstractCollectionTester<E>
32 extends AbstractContainerTester<Collection<E>, E> {
33
34
35 protected Collection<E> collection;
36
37 @Override protected Collection<E> actualContents() {
38 return collection;
39 }
40
41
42 @Override protected Collection<E> resetContainer(Collection<E> newContents) {
43 collection = super.resetContainer(newContents);
44 return collection;
45 }
46
47
48 protected void resetCollection() {
49 resetContainer();
50 }
51
52
53
54
55
56 protected E[] createArrayWithNullElement() {
57 E[] array = createSamplesArray();
58 array[getNullLocation()] = null;
59 return array;
60 }
61
62 protected void initCollectionWithNullElement() {
63 E[] array = createArrayWithNullElement();
64 resetContainer(getSubjectGenerator().create(array));
65 }
66
67
68
69
70
71
72
73
74 protected void expectNullMissingWhenNullUnsupported(String message) {
75 try {
76 assertFalse(message, actualContents().contains(null));
77 } catch (NullPointerException tolerated) {
78
79 }
80 }
81 }